<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/

defined('_JEXEC') or die();

jimport( 'joomla.application.component.model' );

class JAJobBoardModelJAView extends JModel
{
	function getStatisticsInfo()
	{
		$statistics = array();
		//New jobs
		$statistics['ja_jobs']['all'] = $this->countNewRecord_Today('ja_jobs');
		$statistics['ja_jobs']['approved'] = $this->countNewRecord_Today('ja_jobs', ' and status="Approved"');
		$statistics['ja_jobs']['nonapproved'] = $this->countNewRecord_Today('ja_jobs', ' and status="Non-Approved"');
		$statistics['ja_jobs']['waiting'] = $this->countNewRecord_Today('ja_jobs', ' and status="Waiting"');
		
		//New employers
		$statistics['ja_employers']['all'] = $this->countNewRecord_Today('ja_employers');
		
		//New resumes
		$statistics['ja_resumes']['all'] = $this->countNewRecord_Today('ja_resumes');
		
		//New applications
		$statistics['ja_applications']['all'] = $this->countNewRecord_Today('ja_applications');
		
		//New transactions
		$statistics['ja_transactions']['all'] = $this->countNewRecord_Today('ja_transactions');
		$statistics['ja_transactions']['completed'] = $this->countNewRecord_Today('ja_transactions',' and completed=1');
		$statistics['ja_transactions']['uncompleted'] = $this->countNewRecord_Today('ja_transactions',' and completed=0');
		return $statistics;
	}
	function countNewRecord_Today($table_name,$where_more='')
	{
		$db = JFactory::getDBO();
		$query = "SELECT count(id) AS qty FROM #__$table_name WHERE created_date=now()";
		if ($where_more!='')
			$query .= $where_more;
		$db->setQuery($query);
		$qty = $db->getObject();
		return $qty;
	}
}

